<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body{
            height:2000px;
        }

        .top{
            width: 80px;
            height: 80px;
            position: fixed;
            bottom: 80px;
            right: 20px;
            background: #2fa3ff;
            display: none;
        }
    </style>
</head>
<body>
<div class="top"></div>
</body>
</html>
<script src="../js/jquery-1.10.1.js"></script>
<script>
    $(function(){
        $(window).scroll(function(){
            if($(window).scrollTop()>300){
                $(".top").fadeIn();
            }else {
                $(".top").fadeOut();
            }
        });
        $(".top").click(function(){
            $(window).scrollTop(0);
        })
    })
</script>
